﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class setup_user : System.Web.UI.Page
{
    private ClassDB.DB TradeDB = new ClassDB.DB();


    DataTable dt;
    




    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {

            string sql = "exec setup_user @ITYPE = 'S01' ";
            TradeDB.ShowTable(sql, "temp");


          //  Session["mydataset"] = TradeDB.Ds.Tables[0];

          //  DataTable dt = (DataTable)Session["mydataset"];

           


            GridData.DataSource = dt;
            GridData.DataBind();


        }
    }

    protected void btndel_Click(object sender, EventArgs e)
    {
    }

    protected void GridData_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //Label lblid = (Label)(e.Row.FindControl("lbl_id"));
        //if (lblid != null)
        //{
        //    lblid.Text = DataBinder.Eval(e.Row.DataItem, "user_id").ToString();
        //}

        Label lbl_username = (Label)(e.Row.FindControl("lbl_username"));
        if (lbl_username != null)
        {
            lbl_username.Text = DataBinder.Eval(e.Row.DataItem, "user_name").ToString();
        }

        Label lbl_name = (Label)(e.Row.FindControl("lbl_name"));
        if (lbl_name != null)
        {
            lbl_name.Text = DataBinder.Eval(e.Row.DataItem, "first_name").ToString();
        }

        //Label lbl_surname = (Label)(e.Row.FindControl("lbl_surname"));
        //if (lbl_surname != null)
        //{
        //    lbl_surname.Text = DataBinder.Eval(e.Row.DataItem, "last_name").ToString();
        //}

        //Label lbl_login = (Label)(e.Row.FindControl("lbl_login"));
        //if (lbl_login != null)
        //{
        //    lbl_login.Text = DataBinder.Eval(e.Row.DataItem, "login_id").ToString();
        //}

        //Label lbl_password = (Label)(e.Row.FindControl("lbl_password"));
        //if (lbl_password != null)
        //{
        //    lbl_password.Text = DataBinder.Eval(e.Row.DataItem, "user_password").ToString();
        //}

        //Label lbl_tel = (Label)(e.Row.FindControl("lbl_tel"));
        //if (lbl_tel != null)
        //{
        //    lbl_tel.Text = DataBinder.Eval(e.Row.DataItem, "mobile_no").ToString();
        //}

        //Label lbl_disable = (Label)(e.Row.FindControl("lbl_disable"));
        //if (lbl_disable != null)
        //{
        //    lbl_disable.Text = DataBinder.Eval(e.Row.DataItem, "user_disable").ToString();
        //}
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
      //  Session["mydataset"] = TradeDB.Ds.Tables[0];

     //   DataTable dt = (DataTable)Session["mydataset"];
        DataTable workTable = new DataTable("Customers");
        DataRow workRow;

        workTable.Columns.Add("user_name",typeof(int));
        workTable.Columns.Add("first_name", typeof(string));



        for (int i = 0; i <= 59; i++)
        {
            workRow = workTable.NewRow();
            workRow["user_name"] = i;
            workRow["first_name"] = "CustName" + i.ToString();
            workTable.Rows.Add(workRow);
        }



        //DataRow newCustomersRow = dt.NewRow();

        //newCustomersRow["user_name"] = txt_login.Text;
        //newCustomersRow["first_name"] = txt_password.Text;

        //dt.Rows.Add(newCustomersRow);


      //  Session["mydataset"] = dt;

       // DataRow ddt = workTable.Select("TOP 10 ID < 100");
        

        DataView view = new DataView(workTable);

        // Sort by State and ZipCode column in descending order
        //view.Sort = "first_name ASC";
        view.Sort = "user_name ASC";
     


        int plus = 0;
    

        foreach (DataRowView row in view)
        {
            //plus = Convert.ToInt16(row["user_name"]);


            plus = plus + Convert.ToInt16(row["user_name"]);

             


          //  Console.WriteLine(" {0} \t {1}", row["State"], row["ZipCode"]);
        }

       Response.Write(plus);


      

        GridData.DataSource = view;
      
        GridData.DataBind();

    }
}